<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>新增加班申请</span>
        <el-button @click="backUserList" style="float: right; padding: 3px 0" type="text">返回我的加班记录</el-button>
      </div>
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="开始时间" prop="form.startTime">
            <template>
              <el-time-picker
                      v-model="form.startTime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      :picker-options="{
                        format: 'yyyy-MM-dd HH:mm:ss'
                      }"
                      placeholder="开始时间">
              </el-time-picker>
            </template>
          </el-form-item>
          <el-form-item label="结束时间" prop="form.endTime">
            <template>
              <el-time-picker
                      v-model="form.endTime"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      :picker-options="{
                        format: 'yyyy-MM-dd HH:mm:ss'
                      }"
                      placeholder="结束时间">
              </el-time-picker>
            </template>
          </el-form-item>
          <el-form-item label="原因" prop="form.work_process">
            <div class="block" style="width: 500px">
              <el-input style="width: 300px" v-model="form.reason"
                        type="textarea"
                        :rows="2"></el-input>
            </div>
          </el-form-item>
        </el-form>
        <el-button @click="submit" type="primary">提交加班申请</el-button>
      </div>
    </el-card>

  </div>
</template>

<script>

  import { addOverTime } from "../../network/Overtime";

  export default {
    name: "OvertimeAdd",
    data() {
      return {
        form: {
          reason: '',
          startTime: '',
          endTime:'',
        }
      }
    },
    methods: {
      backUserList() {
        this.$router.back(1)
      },
      submit() {
        console.log(this.form)
        addOverTime(this.form).then(res => {
          this.$message.success('添加日报成功')
          setTimeout(() => {
            this.$router.back(1)
          }, 500)
        }, err => {
          this.$message.error('添加日报失败，请检查错误')
        })
      }
    },
  }
</script>

<style scoped>

</style>
